package com.tedu.openmedical.duplicate.copy_purpose.controller;

import com.tedu.openmedical.base.response.JsonResult;
import com.tedu.openmedical.duplicate.copy_purpose.pojo.dto.CopyPurposeParam;
import com.tedu.openmedical.duplicate.copy_purpose.pojo.dto.CopyPurposeQuery;
import com.tedu.openmedical.duplicate.copy_purpose.pojo.vo.CopyPurposeVO;
import com.tedu.openmedical.duplicate.copy_purpose.service.CopyPurposeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "复印用途模板管理")
@Slf4j
@RestController
@RequestMapping("/v1/duplicate/copy_purpose/")
public class CopyPurposeController {
    @Autowired
    private CopyPurposeService copyPurposeService;

    @ApiOperation("查询复印用途模板")
    @GetMapping("select")
    public JsonResult selectTemplate(CopyPurposeQuery query){
        log.debug("查询复印用途模板，query:{}",query);
        List<CopyPurposeVO> list = copyPurposeService.selectTemplate(query);
        return JsonResult.ok(list);
    }

    @ApiOperation("更新复印用途模板")
    @PostMapping("update")
    public JsonResult updateTemplate(CopyPurposeParam param){
        log.debug("新增或更新复印用途，param:{}",param);
        copyPurposeService.updateTemplate(param);
        return JsonResult.ok();
    }

    @ApiOperation("删除复印用途模板")
    @PostMapping("delete/{id}")
    public JsonResult deleteTemplate(@PathVariable Long id){
        log.debug("删除复印用途模板，id:{}",id);
        copyPurposeService.deleteTemplate(id);
        return JsonResult.ok();
    }
}
